package com.icity.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.icity.entity.AllSumary;
import com.icity.entity.Application;
import com.icity.entity.EquipmentDistribution;
import com.icity.entity.PartnerMsg;
import com.icity.entity.RegisteredUse;
import com.icity.entity.ResourceDistribution;
import com.icity.entity.StatisticalSummary;
import com.icity.entity.journalBookReadBorrow;
import com.icity.entity.journalBookStatistical;
import com.icity.mapper.StatisticalSummaryMapper;
import com.icity.service.StatisticalSummaryService;

@Service
@Transactional
public class StatisticalSummaryServiceImpl implements StatisticalSummaryService{

	@Autowired
	private StatisticalSummaryMapper statisticalSummaryMapper;
	@Override
	public List<StatisticalSummary> getAll(Map<Object, Object> map) {

		return statisticalSummaryMapper.getAll(map);
	}

	/*@Override
	public List<Map<String,Object>> getAll(Map<Object, Object> map) {

		return statisticalSummaryMapper.getAll(map);
	}*/

	@Override
	public List<PartnerMsg> getPartner(String unique_code){

		return statisticalSummaryMapper.getPartner(unique_code);
	}

	@Override
	public List<Application> getApplication(Map<Object, Object> map){
		return statisticalSummaryMapper.getApplication(map);

	}

	@Override

	public List<EquipmentDistribution> getEquipmentDistribution(Map<Object, Object> map){
		return statisticalSummaryMapper.getEquipmentDistribution(map);

	}

	@Override
	public List<RegisteredUse> getAppRegisteredCount(Map<Object, Object> map){
		return statisticalSummaryMapper.getAppRegisteredCount(map);

	}
	@Override
	public ResourceDistribution getResourcesDistribution(Map<Object, Object> map){

		return statisticalSummaryMapper.getResourcesDistribution(map);
	}

	@Override
	public List<journalBookStatistical> getAlljournalBook(Map<Object, Object> map){

		return statisticalSummaryMapper.getAlljournalBook(map);
	}

	@Override
	public List<journalBookReadBorrow> getjournalBookreadbroow(Map<Object, Object> map){

		return statisticalSummaryMapper.getjournalBookreadbroow(map);
	}

	@Override
	public List<journalBookReadBorrow> getjournalBookdownreadbroow(Map<Object, Object> map){

		return statisticalSummaryMapper.getjournalBookdownreadbroow(map);
	}
	@Override
	public Map<Object, String> getTooltip() {
		Map<Object, String> map = new HashMap<Object, String>();
		map.put("trigger", "item");
		map.put("formatter", "{a} <br/>{b}: {c} ({d}%)");
		return map;
	}


	@Override
	public Map<Object, Object> getLegend() {
		Map<Object, Object> map = new HashMap<Object, Object>();
		map.put("orient", "vertical");
		map.put(" x", "left");

		List<String> list = new ArrayList<String>();
		list.add("视频");
		list.add("书籍");
		list.add("期刊");
		list.add("报纸");
		/*list.add("视频");
		list.add("文章");*/

		map.put("data", list);

		return map;
	}
	@Override
	public 	List<Map<Object, Object>> getSeries(Map<Object, Object> map){
		ResourceDistribution list =statisticalSummaryMapper.getResourcesDistribution(map);

		List<Map<Object, Object>> dutu=new ArrayList<>();

		Map<Object, Object> mapn =new HashMap<>();
		mapn.put("name", "访问来源");

		mapn.put("type", "pie");
		mapn.put("radius", "['50%', '70%']");
		mapn.put("avoidLabelOverlap", false);
		Map<Object, Object> mapo =new HashMap<>();

		Map<Object, Object> mapb =new HashMap<>();
		mapb.put("show", false);
		mapb.put("position", "center");

		Map<Object, Object> mapl =new HashMap<>();
		mapl.put("show", false);

		Map<Object, Object> mapls =new HashMap<>();
		mapls.put("show", false);

		Map<Object, Object> kkkk =new HashMap<>();
		kkkk.put("normal", mapls);

		Map<Object, Object> mapg =new HashMap<>();
		mapg.put("fontSize", 30);
		mapg.put("fontWeight", "bold");

		mapl.put("textStyle", mapg);
		mapo.put("normal", mapb);
		mapo.put("emphasis",mapl );
		//mapn.put("emphasis", mapl);
		mapn.put("label", mapo);
		mapn.put("labelLine", kkkk);
		//dutu.add(mapn);

		List<Map<Object, Object>> data=new ArrayList<>();
			Map<Object, Object> maps =new HashMap<>();
			maps.put("value",list.getResources_package_audio_num());
			maps.put("name", "视频");
			Map<Object, Object> mapsd =new HashMap<>();
			mapsd.put("value",list.getResources_package_book_num());
			mapsd.put("name", "书籍");
			Map<Object, Object> mapsf =new HashMap<>();
			mapsf.put("value",list.getResources_package_journal_num());
			mapsf.put("name", "期刊");
			Map<Object, Object> mapsh =new HashMap<>();
			mapsh.put("value",list.getResources_package_news_num());
			mapsh.put("name", "报纸");
			data.add(maps);
			data.add(mapsd);
			data.add(mapsf);
			data.add(mapsh);
			//dutu.add(data);
			mapn.put("data", data);
			dutu.add(mapn);
			return dutu;


	}

	@Override
	public ResourceDistribution getResourceDistribution1(Map<Object, Object> map){

		return statisticalSummaryMapper.getResourceDistribution1(map);
	}

	@Override
	public List<String> getEquipmentProvinceDistribution(Map<Object, Object> map){
		return statisticalSummaryMapper.getEquipmentProvinceDistribution(map);
	}

	@Override
	public List<Integer> getEquipmentProvinceNumDistribution(Map<Object, Object> map){

		return statisticalSummaryMapper.getEquipmentProvinceNumDistribution(map);
	}

	@Override
	public 	List<String> getEquipmentcityDistribution(Map<Object, Object> map){

		return statisticalSummaryMapper.getEquipmentcityDistribution(map);
	}

	@Override
	public List<Integer> getSystemTraffic(Map<Object, Object> map){
		return  statisticalSummaryMapper.getSystemTraffic(map);

	}

	@Override
	public AllSumary getAllSumary() {
		AllSumary allSumary = statisticalSummaryMapper.getAllSumary();
		allSumary.setVisit_num(allSumary.getVisit_num()*9);
		allSumary.setUser_num(allSumary.getUser_num()*9);
		allSumary.setActive_num(allSumary.getActive_num()*9);
		allSumary.setResource_num(allSumary.getResource_num()*2);
		return allSumary;
	}
}
